home *** CD-ROM | disk | FTP | other *** search
/ The Games Machine 76 / XENIATGM66.iso / Indiana Jones / Indiana Jones.exe / RESOURCE / PREVIEW.GOB / cog_pyr_bucketpuzzle.cog < prev    next >
Text File  |  1999-11-15  |  11KB  |  421 lines

  1. # Jones 3D Cog Script
  2. #
  3. # pyr_bucketpuzzle.cog
  4. #    
  5. # Control bucket puzzle in pyramid 1
  6. #
  7. # [RKD]
  8. #
  9. # (C) 1998 LucasArts Entertainment Company LLC. All Rights Reserved
  10. # ========================================================================================
  11. symbols
  12. message        startup
  13. message        activated
  14. message        arrived
  15. message        timer
  16.  
  17. # actors
  18. thing    player            nolink    local
  19. thing    indyactor        nolink
  20.  
  21. # camera things
  22. thing    bucketcam        nolink
  23.  
  24. # camera lookthings
  25. thing    bucketcamlook    nolink
  26.  
  27. # world things
  28. thing    bucket
  29. thing    armnobucket
  30. thing    armbucketempty    nolink
  31. thing    armbucketfull    nolink
  32. thing    bigsprig        nolink
  33. thing    lilsprig        nolink
  34.  
  35. thing    activatebox
  36.  
  37. # water things
  38. thing    waterplane        nolink
  39. thing    sumpdump        nolink
  40. thing    circlesplash    nolink
  41. thing    ringghost1        nolink
  42. thing    ringghost2        nolink
  43. thing    mistghost        nolink
  44. thing    tempring        nolink    local
  45. thing    bucketmist        nolink
  46.  
  47. # sounds
  48. sound    bucketon=pyr_bucket_attach.wav            local
  49. sound    bucketpour=pyr_bucket_pour.wav            local
  50. sound    getwater=pyr_bucket_catch_water.wav        local
  51. sound    machinecreak=pyr_bucketmachine_loop.wav    local
  52. sound    bucketslap=jep_sus_crk_3.wav            local
  53. sound    firstturn=jep_sus_crk_2.wav                local
  54.  
  55. # indy saylines
  56. sound    contraption=inxj118.wav        local
  57. sound    doohickey=inxj208.wav        local
  58. sound    gadget=inxj117.wav            local
  59. sound    thingwork=inxj119.wav        local
  60. sound    thatthinggo=inxj113.wav        local
  61.  
  62. # water surface material
  63. material    sumpmat=obj_pyr_a4dump.mat                local
  64. material    entersplash=obj_pyr_a4sfx_splash.mat    local
  65. material    outerpool=gen_a4_water_stillc.mat        local
  66.  
  67. template    ring=+ripples    local
  68. template    mist=H2Ofluefx    local
  69.  
  70. # underwater sectors
  71. sector    watersector0    nolink    # internal
  72. sector    watersector1    nolink    
  73. sector    watersector2    nolink
  74.  
  75. sector    watersector3    nolink    # external
  76. sector    watersector4    nolink
  77. sector    watersector5    nolink
  78. sector    watersector6    nolink
  79. sector    watersector7    nolink
  80.  
  81. #water surfaces
  82. surface    waterface3        nolink    # external
  83. surface    waterface4        nolink
  84. surface    waterface5        nolink
  85. surface    waterface6        nolink
  86. surface    waterface7        nolink
  87.  
  88. #teeter keyframes
  89. keyframe    full2empty=pyr_teeter_full.key    local
  90. keyframe    empty2full=pyr_teeter_empty.key    local
  91.  
  92. #variables
  93. flex    buckettime=0.2    local
  94. flex    bucketdist=0.0    local
  95. flex    waterheight=0.0    local
  96.  
  97. int        wateranimnum=0    local
  98. int        linenum=0        local
  99. int        cursound=0        local
  100. int        nullvalue=0        local
  101.  
  102. # subroutines
  103. flex    startscene=0.0        local
  104. flex    fixcams=0.0            local
  105. flex    makeitgo=0.0        local
  106. flex    changecam=0.0        local
  107. flex    startmachine=0.0    local
  108. flex    bucketlines=0.0        local
  109. end
  110.  
  111.  
  112. code
  113. startup:
  114.     sleep(.01);
  115.  
  116.     SetThingFlags(armbucketfull, 0x10);
  117.     SetThingFlags(armbucketempty, 0x10);
  118.     SetThingFlags(waterplane, 0x10);
  119.     SetThingFlags(sumpdump, 0x10);
  120.     SetThingFlags(bucket, 0x10);
  121.     SetThingFlags(circlesplash, 0x10);
  122.     SetThingFlags(bigsprig, 0x80000);
  123.     SetThingFlags(lilsprig, 0x80000);
  124.  
  125.     SetThingLight(circlesplash, '0.4 0.4 1', .001, .01);
  126.     SetThingLight(waterplane, '.8 .8 1', .001, .01);
  127.  
  128.     AttachThingToThing(bucket, armnobucket);
  129.     AttachThingToThing(circlesplash, waterplane);
  130.     AttachThingToThing(mistghost, waterplane);
  131.     AttachThingToThing(ringghost1, waterplane);
  132.     AttachThingToThing(ringghost2, waterplane);
  133.  
  134.     SetFaceGeoMode(waterface3, 0);
  135.     SetFaceGeoMode(waterface4, 0);
  136.     SetFaceGeoMode(waterface5, 0);
  137.     SetFaceGeoMode(waterface6, 0);
  138.     SetFaceGeoMode(waterface7, 0);
  139.  
  140.     player = GetLocalPlayerThing();
  141.     
  142.     return;
  143.  
  144. activated:
  145. # ---> Bucket
  146.  
  147.     #if bucket is not activated, or gone;
  148.     if (bucket == -1) return;
  149.     if ((GetSenderRef() != bucket) && (GetSenderRef() != activatebox)) return;
  150.     
  151.     DeselectWeaponWait(GetLocalPlayerThing());
  152.     
  153.     # if player isn't holding the bucket, call some saylines
  154.     if (GetCurItem(player) != 117)
  155.     {
  156.         call bucketlines;
  157.         return;
  158.     }
  159.  
  160. MAKEITGO:
  161.     call startscene;
  162.     call changecam;
  163.  
  164.     #play actor anim and make bucket visible
  165.     PlayMode(indyactor, 60, 0);
  166.     sleep(.5);
  167.     nullvalue = PlaySoundThing(bucketon, sumpdump, 1, 1, 10, 0);
  168.     ClearThingFlags(bucket, 0x10);
  169.     
  170.     # take bucket out of inventory, pause
  171.     ChangeInv(player, 117, -1);
  172.     sleep(1);
  173.     
  174.     #play actor anim to push bucket
  175.     PlayMode(indyactor, 61, 0);
  176.     sleep(.5);
  177.     nullvalue = PlaySoundThing(bucketslap, sumpdump, 1, 1, 10, 0);
  178.     nullvalue = PlaySoundThing(firstturn, sumpdump, 1, 1, 10, 0);
  179.     Rotate(armnobucket, 30, 1, buckettime);
  180.     
  181.     #pull camera back
  182.     MoveToFrame(bucketcam, 1, 1.6);
  183.     MoveToFrame(bucketcamlook, 1, 1.4);
  184.     SetCameraFOV(100, 2, 3);
  185.     
  186.     return;
  187.  
  188. arrived:
  189. # ---> ArmNoBucket
  190.     
  191.     #when bucket swings under the flow
  192.     if (bucketdist == 240)
  193.     {
  194.         call startmachine;
  195.         return;
  196.     }
  197.     
  198.     #Make bucket lose momentum
  199.     buckettime = buckettime + .03;
  200.     bucketdist = bucketdist + 30;
  201.     Rotate(armnobucket, 30, 1, buckettime);
  202.     return;
  203.     
  204. bucketlines:
  205.     # if player is just activating without an item
  206.     if (GetCurItem(player) == 0)
  207.     {
  208.         # freeze player, start scene
  209.         StartCutscene(1);
  210.         StopThing(player);
  211.         SetActorFlags(player, 0x200000);
  212.         SetExtCamOffset('-0.15 -0.05 0.04');
  213.         sleep(.5);
  214.  
  215.         # play the hint line and cycle to the next one
  216.         PlayVoice(player, contraption[linenum], 1, 1);
  217.         linenum = linenum + 1;
  218.         if (linenum == 4) linenum = 0;
  219.         sleep(.5);
  220.  
  221.         # restore to normal
  222.         RestoreExtCam();
  223.         ClearActorFlags(player, 0x200000);
  224.         EndCutscene();
  225.     }
  226.     return;
  227.  
  228.  
  229. startmachine:
  230.     #Destroy non-animating assembly
  231.     DestroyThing(bucket);
  232.     bucket = -1;
  233.     DestroyThing(armnobucket);
  234.  
  235.     #splash
  236.     nullvalue = CreateThing(mist, bucketmist);
  237.     nullvalue = PlaySoundThing(getwater, bucketmist, 1, 1, 10, 0);
  238.     
  239.     #Move camera lookthing downward and widen the view
  240.     MoveToFrame(bucketcamlook, 2, 1);
  241.  
  242.     #make animated version visible and play first keyframe
  243.     ClearThingFlags(armbucketfull, 0x10);
  244.     nullvalue = PlaySoundThing(machinecreak, armbucketfull, 1, 1, 12, 1);
  245.     nullvalue = PlayKey(armbucketfull, full2empty, 4, 0x12, 1);
  246.  
  247.     #create splash animation, make full bucket invisible, and show water plane
  248.     SetTimerEx(.001, 2, 0, 0);
  249.     SetThingFlags(armbucketfull, 0x10);
  250.  
  251.     #set external water sectors
  252.     SetSectorFlags(watersector3, 2);
  253.     SetSectorFlags(watersector4, 2);
  254.     SetSectorFlags(watersector5, 2);
  255.     SetSectorFlags(watersector6, 2);
  256.     SetSectorFlags(watersector7, 2);
  257.  
  258.     #set watersector face flags to shallow water
  259.     SetSectorSurfFlags(watersector3, 0x40000);
  260.     SetSectorSurfFlags(watersector4, 0x40000);
  261.     SetSectorSurfFlags(watersector5, 0x40000);
  262.     SetSectorSurfFlags(watersector6, 0x40000);
  263.     SetSectorSurfFlags(watersector7, 0x40000);
  264.  
  265.     #set external water surface flags
  266.     SetFaceGeoMode(waterface3, 4);
  267.     SetFaceGeoMode(waterface4, 4);
  268.     SetFaceGeoMode(waterface5, 4);
  269.     SetFaceGeoMode(waterface6, 4);
  270.     SetFaceGeoMode(waterface7, 4);
  271.  
  272.     # make outer water surface animate
  273.     nullValue = MaterialAnim(outerpool, 10, 1);
  274.     
  275.     # put some health out there (thanks to Mighty Joe T.)
  276.     ClearThingFlags(bigsprig, 0x80000);
  277.     ClearThingFlags(lilsprig, 0x80000);
  278.     
  279.     #create escape for while loop before it starts
  280.     SetTimerEx(6, 1, 0, 0);
  281.  
  282.     # Indy is amazed
  283.     PlayVoice(indyactor, thatthinggo, 1, 0);
  284.  
  285.     #start empty/fill cycle
  286.     while (1)
  287.     {
  288.         #prepare for bucket splash
  289.         SetTimerEx(1.3, 3, 0, 0);
  290.         
  291.         #make empty bucket visible long enough to play keyframe
  292.         ClearThingFlags(armbucketempty, 0x10);
  293.         nullvalue = PlayKey(armbucketempty, empty2full, 4, 0x12, 1);
  294. //        PlayKey(armbucketempty, empty2full, 4, 0x12, 1);
  295.         SetThingFlags(armbucketempty, 0x10);
  296.     
  297.         #make full bucket visible long enough to play keyframe
  298.         ClearThingFlags(armbucketfull, 0x10);
  299.         nullvalue = PlayKey(armbucketfull, full2empty, 4, 0x12, 1);
  300.         SetThingFlags(armbucketfull, 0x10);
  301.  
  302.         SetTimerEx(.001, 2, 0, 0);
  303.     }
  304.     return;
  305.     
  306. changecam:
  307.     #change to bucketcam
  308.     SetCameraFocus(2, bucketcam);
  309.     SetCameraSecondaryFocus(2, bucketcamlook);
  310.     SetCurrentCamera(2);
  311.     ResetCameraFOV(0, 0);
  312.     return;
  313.  
  314. startscene:
  315.     call fixcams;
  316.  
  317.     StartCutscene(1);
  318.     CopyOrientAndPos(indyactor, player);
  319.     CopyPlayerHolsters(player, indyactor);
  320.     ClearThingFlags(indyactor, 0x80000);
  321.     StopThing(player);
  322.     SetActorFlags(player, 0x200000);
  323.     SetThingFlags(player, 0x80000);
  324.         
  325.     return;
  326.             
  327. timer:
  328.     if (GetSenderID() == 1)
  329.     {
  330.         #end cutscene
  331.         call fixcams;
  332.  
  333.         CopyOrientAndPos(indyactor, player);
  334.         SetThingFlags(indyactor, 0x80000);
  335.         ClearThingFlags(player, 0x80000);
  336.         ClearActorFlags(player, 0x200000);
  337.  
  338.         # Establish a camera position near Indy and prep follow-cam...            
  339.         SetCameraPosition(1, VectorAdd(VectorTransformToOrient(player, '-0.25 -0.1 0.0'), GetThingPos(player)));    
  340.         SetCurrentCamera(1);
  341.         
  342.         EndCutscene();
  343.     }
  344.  
  345.     if (GetSenderID() == 2)
  346.     {
  347.         #animate sump thing
  348.         nullvalue = SetMaterialCel(sumpmat, 0);
  349.         ClearThingFlags(sumpdump, 0x10);
  350.         nullValue = MaterialAnim(sumpmat, 20, 0);
  351.  
  352.         nullvalue = PlaySoundThing(bucketon, armbucketempty, 1, 1, 12, 0);
  353.         nullvalue = PlaySoundThing(bucketpour, sumpdump, 1, 1, 10, 0);
  354.         sleep(.12);
  355.         
  356.         #create ring and mist
  357.         tempring = CreateThing(ring, circlesplash);
  358.         nullvalue = AnimateSpriteSize(tempring, '0.1 0.1 1', '0.3 0.3 0', 2);
  359.         nullvalue = CreateThing(mist, mistghost);
  360.  
  361.         ClearThingFlags(waterplane, 0x10);
  362.         
  363.         #make water rise a bit when full bucket hits bottom
  364.         if (waterheight < .04)
  365.         {
  366.             nullValue = MoveThing(waterplane, '0 0 1', .002, .5);
  367.             waterheight = waterheight + .002;
  368.  
  369.             # if above .1 meters, make lowest sector waterish
  370.             if (waterheight > 0.01)
  371.             {
  372.                 SetSectorFlags(watersector0, 2);
  373.                 SetSectorSurfFlags(watersector0, 0x40000);
  374.             }
  375.             
  376.             # if above .3 meters, make upper sector waterish
  377.             if (waterheight > .03)
  378.             {
  379.                 SetSectorSurfFlags(watersector1, 0x20000);
  380.                 SetSectorSurfFlags(watersector2, 0x20000);
  381.             }
  382.         }
  383.  
  384.         #display and animate circlesplash
  385.         ClearThingFlags(circlesplash, 0x10);
  386.         wateranimnum = MaterialAnim(entersplash, 14, 0);
  387.         
  388.         sleep(.1);
  389.         SetThingFlags(sumpdump, 0x10);
  390.         
  391.         #auxiliary water rings and mist
  392.         tempring = CreateThing(ring, ringghost1);
  393.         nullValue = AnimateSpriteSize(tempring, '0.1 0.1 1', '0.3 0.3 0', 2);
  394.         tempring = CreateThing(ring, ringghost2);
  395.         nullValue = AnimateSpriteSize(tempring, '0.1 0.1 1', '0.3 0.3 0', 2);
  396.         
  397.         //WaitForAnimStop(wateranimnum);
  398.         //SetThingFlags(circlesplash, 0x10);
  399.     }
  400.     
  401.     if (GetSenderID() == 3)
  402.     {
  403.         nullvalue = CreateThing(mist, bucketmist);
  404.         nullvalue = PlaySoundThing(getwater, bucketmist, 1, 1, 10, 0);
  405.     }
  406.  
  407.     return;
  408.  
  409. fixcams:
  410.     #reset camera settings
  411.     ResetCameraFOV(0, 0);
  412.     SetCameraPosInterp(2, 0);
  413.     SetCameraLookInterp(2, 0);
  414.     SetCameraPosInterp(1, 0);
  415.     SetCameraLookInterp(1, 0);
  416.     RestoreExtCam();
  417.     return;
  418.  
  419. end
  420.  
  421.